/**
 * 
 */
package com.coder520.sync_learning.demo;

import java.util.concurrent.TimeUnit;

/**
 * @author zhaoyibo
 *
 */
public class HeapMutex {
	final static Object mutex=new Object();
	public void accessResource() {
		synchronized (mutex) {
			try {
				TimeUnit.MINUTES.sleep(10);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
			
		}
	}
	
	public static void main(String[] args) {
		final HeapMutex mutex=new HeapMutex();
		for (int i = 0; i < 5; i++) {
			new Thread(mutex :: accessResource).start();
		}
	}
}
